package com.chatdating.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chatdating.entity.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    @Select("SELECT * FROM comments WHERE post_id = #{postId} ORDER BY create_time DESC")
    List<Comment> findByPostId(Long postId);
    @Select("SELECT COUNT(*) FROM comments WHERE post_id = #{id}")
    Integer getCommentCountByPostId(Long id);
    @Delete("DELETE FROM comments WHERE id = #{id}")
    void delComment(Integer id);
    @Select("SELECT * FROM comments WHERE post_id = #{pid}")
    List<Comment> getCommentList(Integer pid);
}
